Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

readline-sync

Package Overview
Dependencies
Maintainers
1
Versions
65
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

readline-sync

Synchronous Readline for interactively running to have a conversation with the user via a console(TTY).

  • 1.4.10
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
950K
decreased by-49.53%
Maintainers
1
Weekly downloads
 
Created

What is readline-sync?

The readline-sync package is a Node.js module that allows synchronous readline interface for reading input from the console. It is designed to make it easy to prompt and get user input in a synchronous manner without the complexities of asynchronous callbacks. This package is particularly useful for CLI (Command Line Interface) applications where you need to ask questions, get user input, or display messages sequentially.

What are readline-sync's main functionalities?

Basic Input

This feature allows you to prompt the user for input and store their response. The `question` method displays a message to the user and waits for their input.

const readlineSync = require('readline-sync');
let userName = readlineSync.question('May I have your name? ');
console.log('Hi ' + userName + '!');

Password Input

This feature is used for password or sensitive information inputs. It hides the user's input on the screen to protect sensitive information.

const readlineSync = require('readline-sync');
let password = readlineSync.question('Enter your password: ', {
  hideEchoBack: true // The typed text on screen is hidden by `*` (default).
});

Multiple Choice List

This feature allows you to present a list of options to the user and let them choose. It is useful for menus or any choice-based interaction.

const readlineSync = require('readline-sync');
let animals = ['Lion', 'Elephant', 'Crocodile', 'Giraffe', 'Hippo'],
  index = readlineSync.keyInSelect(animals, 'Which animal?');
console.log('Ok, ' + animals[index] + ' goes to your room.');

Other packages similar to readline-sync

Keywords

FAQs

Package last updated on 27 Jul 2019

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc